home *** CD-ROM | disk | FTP | other *** search
/ Computer Life 1995 December / Computer Life December 1995.iso / claris / applicat / cw10bv1 / disk1 / msdetect.inc < prev    next >
Encoding:
Text File  |  1993-03-18  |  2.7 KB  |  81 lines

  1. '**************************************************************************
  2. '*************************  Setup Detect API's  ***************************
  3. '**************************************************************************
  4.  
  5. ''detect
  6.  
  7. DECLARE FUNCTION LcbFreeDrive LIB "msdetstf.dll" (nDrive%) AS LONG
  8. DECLARE FUNCTION FIsValidDrive LIB "msdetstf.dll" (nDrive%) AS INTEGER
  9. DECLARE FUNCTION CbGetIniKeyString LIB "msdetstf.dll" (szFile$, szSect$, szKey$, szBuf$, cbBuf%) AS INTEGER
  10. DECLARE FUNCTION FDoesFileExist LIB "msdetstf.dll" (szFileName$, mode%) AS INTEGER
  11.  
  12.  
  13.  
  14.  
  15. '*************************************************************************
  16. '****************  Detect Basic Wrapper Declarations  ********************
  17. '*************************************************************************
  18.  
  19.  
  20. '' detect
  21.  
  22. DECLARE FUNCTION IsDriveValid (szDrive$) AS INTEGER
  23. DECLARE FUNCTION GetFreeSpaceForDrive (szDrive$) AS LONG
  24. DECLARE FUNCTION GetIniKeyString (szFile$, szSect$, szKey$) AS STRING
  25. DECLARE FUNCTION DoesFileExist (szFile$, mode%) AS INTEGER
  26.  
  27.  
  28.  
  29. '*************************************************************************
  30. FUNCTION IsDriveValid (szDrive$) STATIC  AS INTEGER
  31.     if FValidDrive(szDrive$) = 0 then
  32.         BadArgErr 1, "IsDriveValid", szDrive$
  33.     end if
  34.     IsDriveValid = FIsValidDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  35. END FUNCTION
  36.  
  37.  
  38. '*************************************************************************
  39. FUNCTION GetFreeSpaceForDrive (szDrive$) STATIC  AS LONG
  40.     if FValidDrive(szDrive$) = 0 then
  41.         BadArgErr 1, "GetFreeSpaceForDrive", szDrive$
  42.     end if
  43.     GetFreeSpaceForDrive = LcbFreeDrive(ASC(UCASE$(szDrive$)) - ASC("A") + 1)
  44. END FUNCTION
  45.  
  46.  
  47. '*************************************************************************
  48. FUNCTION GetIniKeyString (szFile$, szSect$, szKey$) STATIC  AS STRING
  49.     if FValidIniFile(szFile$) = 0 then
  50.         n% = 1
  51.     elseif szKey$ = "" then
  52.         n% = 3
  53.     else
  54.         n% = 0
  55.     end if
  56.     if n% > 0 then
  57.         BadArgErr n%, "GetIniKeyString", szFile$+", "+szSect$+", "+szKey$
  58.     end if
  59.  
  60.     cb% = 512
  61.     szBuf$ = STRING$(cb%, 32)
  62.     cbRet% = CbGetIniKeyString(szFile$, szSect$, szKey$, szBuf$, cb%)
  63.     GetIniKeyString = szBuf$
  64.     IF cbRet% >= cb% THEN
  65.         StfApiErr saeOvfl, "GetIniKeyString", szFile$+", "+szSect$+", "+szKey$
  66.         ERROR STFERR
  67.     END IF
  68.     szBuf$ = ""
  69. END FUNCTION
  70.  
  71.  
  72. '*************************************************************************
  73. FUNCTION DoesFileExist (szFileName$, mode%) STATIC  AS INTEGER
  74. '$ifdef DEBUG
  75.     if FValidFATPath(szFileName$) = 0 then
  76.         BadArgErr 1, "DoesFileExist", szFileName$+", "+STR$(mode%)
  77.     end if
  78. '$endif ''DEBUG
  79.     DoesFileExist = FDoesFileExist(szFileName$, mode%)
  80. END FUNCTION
  81.